from flask import Flask
from flask_restful import Api
from flask_restful_swagger import swagger
from com.BookResources import BookResources
from com.Database import init_database
from com.Mainfest import set_app_mainfest

app = Flask(__name__)
# api = Api(app)
api = swagger.docs(Api(app), apiVersion=0.1,
                   description='所有POST、PUT类型请求，不需要设置参数名称，直接向后台提交JSON数据；Python版Swagger测试有BUG，请使用PostMan测试')
set_app_mainfest(app, 'manifest.yml')
init_database(app, app.config['database']['uri'])

api.add_resource(BookResources, '/books')

if __name__ == '__main__':
    app.run(debug=True, port=app.config['server']['port'])